#第一题、通过datetime模块完成时间戳, datetime.datetime对象, 格式化字符串三者之间的转换
import math
import time
import datetime
#datetime.datetime -> str
now = datetime.datetime.now(tz=None)
print(now.strftime("%Y-%m-%d %H:%M:%S"))
#str -> datetime.datetime
print(datetime.datetime.strptime(now, "%Y-%m-%d %H:%M:%S"))
#datetime.datetime -> timestamp
print(now.timestamp())
#timestamp -> datetime.datetime
ts = now.timestamp()
print(datetime.datetime.fromtimestamp(ts, tz=None))

#第二题、封装一个函数get_date(day_delta), 如果传入的是-1 , 输出就是字符串日期2020-01-07.
from datetime import timedelta
print(now + timedelta(days=-1))



